package com.gee.spring.cloud.feign.flow.config;

import com.gee.spring.cloud.feign.flow.execute.WorkExecutor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * desc:
 *
 * @author gee
 * @since 2021-04-01 17:12:16
 */
@Configuration
public class FeignFlowAutoConfig{

    @Bean
    @ConditionalOnMissingBean
    public ThreadPoolExecutor feignFlowThreadPoolExecutor() {
        return new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors() * 2, 1024,
                15L, TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(),
                WorkExecutor.defaultThreadFactory());
    }
}
